local dye_table = furniture.dyes

for i in ipairs(dye_table) do
   local name = dye_table[i][1]
   local desc = dye_table[i][2]
   local hex = dye_table[i][3]

   minetest.register_node('furniture:bed1_'..name, {
      description = 'Bed with '..desc..' Blankets',
      drawtype = 'mesh',
      mesh = 'furniture_bed1.obj',
      tiles = {'furniture_bed1_wood.png', 'furniture_bed1_sheets.png'},
      overlay_tiles = {{name = '(furniture_bed1_sheets.png^[multiply:'..hex..')^furniture_bed1_mask.png', color = 'white'}},
      use_texture_alpha = 'clip',
      paramtype = 'light',
      paramtype2 = 'colorfacedir',
      palette = 'furniture_stain_palette.png',
      selection_box = {
         type = 'fixed',
         fixed = {{-.5, -.5, -.5, .5, 0, 1.5},
                  {-.5, 0, 1.35, .5, .5, 1.5}}
               },
      collision_box = {
         type = 'fixed',
         fixed = {{-.5, -.5, -.5, .5, 0, 1.5},
                  {-.5, 0, 1.35, .5, .5, 1.5}}
               },
      groups = {breakable=1},
      on_rightclick = furniture.right_click,
      on_punch = furniture.punch
   })

   minetest.register_node('furniture:bed_double1_'..name, {
      description = 'Double Bed with '..desc..' Blankets',
      drawtype = 'mesh',
      mesh = 'furniture_bed_double1.obj',
      tiles = {'furniture_bed_double1_wood.png', 'furniture_bed_double1_sheets.png'},
      overlay_tiles = {{name = '(furniture_bed_double1_sheets.png^[multiply:'..hex..')^furniture_bed_double1_mask.png', color = 'white'}},
      use_texture_alpha = 'clip',
      paramtype = 'light',
      paramtype2 = 'colorfacedir',
      palette = 'furniture_stain_palette.png',
      selection_box = {
         type = 'fixed',
         fixed = {{-.5, -.5, -.5, 1.5, 0, 1.5},
                  {-.5, 0, 1.35, 1.5, .5, 1.5}}
               },
      collision_box = {
         type = 'fixed',
         fixed = {{-.5, -.5, -.5, 1.5, 0, 1.5},
                  {-.5, 0, 1.35, 1.5, .5, 1.5}}
               },
      groups = {breakable=1},
      on_rightclick = furniture.right_click,
      on_punch = furniture.punch
   })

end

minetest.register_node('furniture:sleeping_mat', {
   description = 'Sleeping Mat',
   drawtype = 'mesh',
   mesh = 'furniture_sleeping_mat.obj',
   tiles = {'furniture_sleeping_mat.png'},
   paramtype = 'light',
   paramtype2 = 'facedir',
   selection_box = {
      type = 'fixed',
      fixed = {-.5, -.5, -.5, .5, -.25, 1.5},
      },
   collision_box = {
      type = 'fixed',
      fixed = {-.5, -.5, -.5, .5, -.25, 1.5},
      },
   groups = {breakable=1}
})

minetest.register_node('furniture:nightstand_1', {
   description = 'Nightstand',
   drawtype = 'mesh',
   mesh = 'furniture_nightstand_1.obj',
   tiles = {'furniture_nightstand_1.png'},
   paramtype = 'light',
   paramtype2 = 'colorfacedir',
   palette = 'furniture_stain_palette.png',
   selection_box = {
      type = 'fixed',
      fixed = {-.5, -.5, -.25, .5, .5, .5},
      },
   collision_box = {
      type = 'fixed',
      fixed = {-.5, -.5, -.25, .5, .5, .5},
      },
   groups = {breakable=1, stash=1},
   on_rightclick = furniture.right_click,
   on_punch = furniture.punch
})

minetest.register_node('furniture:dresser1_wide', {
   description = 'Wide Dresser',
   drawtype = 'mesh',
   mesh = 'furniture_dresser1_wide.obj',
   tiles = {'furniture_dresser1_wide.png'},
   paramtype = 'light',
   paramtype2 = 'colorfacedir',
   palette = 'furniture_stain_palette.png',
   selection_box = {
      type = 'fixed',
      fixed = {-.5, -.5, -.375, 1.5, .5, .5},
      },
   collision_box = {
      type = 'fixed',
      fixed = {-.5, -.5, -.375, 1.5, .5, .5},
      },
   groups = {breakable=1, stash=1},
   on_rightclick = furniture.right_click,
   on_punch = furniture.punch
})

minetest.register_node('furniture:dresser1_tall', {
   description = 'Tall Dresser',
   drawtype = 'mesh',
   mesh = 'furniture_dresser1_tall.obj',
   tiles = {'furniture_dresser1_tall.png'},
   paramtype = 'light',
   paramtype2 = 'colorfacedir',
   palette = 'furniture_stain_palette.png',
   selection_box = {
      type = 'fixed',
      fixed = {-.5, -.5, -.375, .5, 1.5, .5},
      },
   collision_box = {
      type = 'fixed',
      fixed = {-.5, -.5, -.375, .5, 1.5, .5},
      },
   groups = {breakable=1, stash=1},
   on_rightclick = furniture.right_click,
   on_punch = furniture.punch
})
